<?php

/**
 * 分销中心（提现） - AM
 * 版本：2.0
 */

global $_W, $_GPC;
$openid = m('user')->getOpenid();

if ($_W['isajax']) {
	$member = m('member')->getMember($openid);
	$recordPrice = $this->model->getCommissionRecordPrice($openid, array( 'total', 'ok', 'lock' , 'apply', 'check', 'pay' ));

	$member['commission_total'] = !empty( $recordPrice['total'] ) ? number_format($recordPrice['total'], 2) : 0;
	$member['commission_ok'] = !empty( $recordPrice['ok'] ) ? number_format($recordPrice['ok'], 2) : 0;
	$member['commission_lock'] = !empty( $recordPrice['lock'] ) ? number_format($recordPrice['lock'], 2) : 0;
	$member['commission_apply'] = !empty( $recordPrice['apply'] ) ? number_format($recordPrice['apply'], 2) : 0;
	$member['commission_check'] = !empty( $recordPrice['check'] ) ? number_format($recordPrice['check'], 2) : 0;
	$member['commission_pay'] = !empty( $recordPrice['pay'] ) ? number_format($recordPrice['pay'], 2) : 0;

	$cansettle = $member['commission_ok'] > 0 && $member['commission_ok'] >= floatval($this->set['withdraw']);

	show_json(1, array('cansettle' => $cansettle, 'settlemoney' => number_format(floatval($this->set['withdraw']), 2), 'member' => $member, 'set' => $this->set));
}
include $this->template('withdraw');